 $(function(){
	 $("#grid").datagrid({
		queryParam:{}, 
	    columns:[[
	    	{field:'name',title:'月份',width:100},
	    	{field:'y',title:'销售额',width:100}
	    ]],
		singleSelect:true,
		onLoadSuccess:function(data){
			//alert(JSON.stringify(data));
			showChart(data.rows);
		}
	 });
		$('#btnSearch').bind('click',function(){
			//把表单数据转换成json对象
			var formData = $('#searchForm').serializeJSON();
			$('#grid').datagrid('load',formData);
			$('#grid').datagrid({
			url:'report_trendReport',	
			queryParams:formData
				
			});
		});
 });
 
 function showChart(_data){
	 var months=new Array();
	 for(var i=1;i<13;i++)
		 months.push(i+"月");
	 $('#trendChart').highcharts({
	        title: {
	            text: $('#year').combobox('getValue')+"年销售趋势分析",
	            x: -20 //center
	        },
	        subtitle: {
	            text: 'Source: WorldClimate.com',
	            x: -20
	        },
	        xAxis: {
	            categories: months
	        },
	        yAxis: {
	            title: {
	                text: '销售额'
	            },
	            plotLines: [{
	                value: 0,
	                width: 1,
	                color: '#808080'
	            }]
	        },
	        tooltip: {
	            valueSuffix: '元'
	        },
	        legend: {
	            layout: 'vertical',
	            align: 'bottom',
	            verticalAlign: 'middle',
	            borderWidth: 0
	        },
	        series: [{
	            name: '销售趋势图',
	            data: $('#grid').datagrid('getRows')
	        }]
	    });	 
 } 